﻿@model Model.AppUserList
@{
    ViewBag.Title = "LocationInventoryBatch";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#cellNo').combobox('setValue', '无');
            InitGrid();

        });
        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            if (row.QUALITYSTATUS == "1") { edit(row); }

        });

        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑商品信息', function () {
                $('#txtGoodsCode').val(row.GOODSCODE);
                $('#txtGoodsName').val(row.GOODSNAME);
                $('#hiddenInventoryId').val(row.LOCATIONINVENTORYID);
                $('#hiddenOverdays').val(row.OVERDAYS);

                $('#txtGoodsCode').attr("readonly", true);
                $('#txtGoodsName').attr("readonly", true);

            });
        }
        function saveData(isClose) {
            var txtNumber = $('#txtNumber').val();
            var hiddenOverdays = $('#hiddenOverdays').val();


            if (eval(txtNumber) >= eval(hiddenOverdays)) {
                layer.msg("解锁天数不能大于等于临保天数！", 2);
            } else {
                HandleRequest.submitForm('location', '@Url.Action("SaveData", "LocationInventoryBatch")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }

    }
    function InitGrid() {
        var txtGOODSCODE = $('#txtGOODSCODE').val();
        var txtGOODSNAME = $('#txtGOODSNAME').val();
        var selecCellNo = $('#cellNo').combobox('getValue');
        var selectSaleDays = $('#saleDays').combobox('getValue');

        queryParams = {
            goodsCode: txtGOODSCODE,
            goodsName: txtGOODSNAME,
            cellNo: selecCellNo,
            saleDays: selectSaleDays
        }
        HandleData.InitDataGrid('dg', '/LocationInventoryBatch/InitJsonResult', 'toolbar', queryParams, 'LOCATIONINVENTORYID', true, function (data) { },
            function (rowIndex, rowData) {//双击
                if (rowData.QUALITYSTATUS == "1") {
                    edit(rowData);
                }

            });
    }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>商品编码:
                    </td>
                    <td>
                        <input id="txtGOODSCODE" name="txtGOODSCODE" style="width: 154px" />
                    </td>
                    <td>商品名称:
                    </td>
                    <td>
                        <input id="txtGOODSNAME" name="txtGOODSNAME" style="width: 154px" />
                    </td>
                    <td>库位:
                    </td>
                    <td>
                        <input id="cellNo" class="easyui-combobox" name="cellNo" style="width: 155px;" data-options="required:true,valueField:'CELLNO',textField:'CELLNO',url:'@Url.Action("CellNoList", "BaseData", new { })',editable:false">
                    </td>
                    <td>是否解锁:
                    </td>
                    <td>
                        <select id="saleDays" class="easyui-combobox" name="saleDays" style="width: 154px;">
                            <option value="0">临保</option>
                            <option value="1">解锁</option>
                        </select>
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>
                </tr>
            </table>
        </form>

    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="货位商品库存信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'LOCATIONINVENTORYID',width:30">货位库存ID</th>
                    <th data-options="field:'GOODSBATCHCODE',width:50">商品批次号</th>
                    <th data-options="field:'LOCATIONCODE',width:50">货位编码</th>
                    <th data-options="field:'GOODSCODE',width:50">商品编码</th>
                    <th data-options="field:'GOODSNAME',width:50">商品名称</th>
                    <th data-options="field:'WAREHOUSENAME',width:30">仓库</th>
                    <th data-options="field:'CELLNO',width:50">库位</th>
                    <th data-options="field:'QTY',width:30">库存数</th>
                    <th data-options="field:'UNITNAME',width:30">单位</th>
                    <th data-options="field:'PRODUCTIONDATE',width:80">生产日期</th>
                    <th data-options="field:'EXPIRYDAYS',width:30">保质天数</th>
                    <th data-options="field:'DIFFDAYS',width:30">已过天数</th>
                    <th data-options="field:'OVERDAYS',width:30">临保天数</th>
                    <th data-options="field:'SALEDAYS',width:30">解锁天数</th>
                    <th data-options="field:'QUALITYSTATUS',width:30, align: 'center', sortable: true, formatter:function(value, rowData, rowIndex){ return FormatData.formatQualityStatus(value);}">状态</th>

                </tr>
            </thead>
        </table>
    </div>

    <div id="dlg" class="easyui-dialog" style="width: 520px; height: 150px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>商品编码:
                    </td>
                    <td colspan="2">
                        <input id="hiddenInventoryId" name="hiddenInventoryId" type="hidden" />
                        <input id="hiddenOverdays" name="hiddenOverdays" type="hidden" />
                        <input id="txtGoodsCode" name="txtGoodsCode" class="easyui-validatebox" style="width: 154px" data-options="required:true" />
                    </td>
                    <td>商品名称:
                    </td>
                    <td colspan="2">
                        <input id="txtGoodsName" name="txtGoodsName" class="easyui-validatebox" style="width: 154px" data-options="required:true" />
                    </td>
                </tr>

                <tr>
                    <td>解锁天数:
                    </td>
                    <td colspan="4">
                        <input id="txtNumber" name="txtNumber" class="easyui-validatebox" style="width: 100px" validtype="integer['#txtNumber']" />
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(true)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =false },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              
            }
        }
    }
})

</body>


